package com.hwg.emp.service.impl;

import java.util.List;

import com.hwg.emp.common.dto.KeysQueryDto;
import com.hwg.emp.common.service.CommonService;
import com.hwg.emp.common.util.DBUtil;
import com.hwg.emp.dao.DaoFactory;
import com.hwg.emp.dao.OvertimeDAO;
import com.hwg.emp.dto.OvertimeDto;
import com.hwg.emp.dto.PageBean;
import com.hwg.emp.model.OvertimeMD;
import com.hwg.emp.service.OvertimeService;

public class OvertimeServiceImpl extends CommonService implements OvertimeService{
	private OvertimeDAO overtimedao=DaoFactory.getDao(OvertimeDAO.class);
	@Override
	public int selectOvertimeByKey(KeysQueryDto dto, List<OvertimeMD> pageData) throws Exception {
		// TODO Auto-generated method stub
		return overtimedao.selectOvertimeByKey(dto, pageData);
	}
	@Override
	public int selectEmpOvertime(String deptId) throws Exception {
		// TODO Auto-generated method stub
		return overtimedao.selectEmpOvertime(deptId);
	}
	@Override
	public List<OvertimeDto> selectEmpOvertime(String deptId, PageBean pageBean) throws Exception {
		// TODO Auto-generated method stub
		return overtimedao.selectEmpOvertime(deptId, pageBean);
	}
	@Override
	public boolean addEmpOvertime(OvertimeDto overtimeDto) throws Exception {
		// TODO Auto-generated method stub
		DBUtil.beginTranscation();
		boolean flag = false;
		try{
			flag = overtimedao.addEmpOvertime(overtimeDto);
			DBUtil.commitTranscation();
		}catch(Exception e){
			DBUtil.rollbackTranscation();
			e.printStackTrace();
		}
		
		return flag;
	}
	@Override
	public boolean deleteEmpOvertime(String[] OvertimeDtoId) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		DBUtil.beginTranscation();
		for (int i = 0; i < OvertimeDtoId.length; i++) {
			try{
				flag = overtimedao.deleteEmpOvertime(OvertimeDtoId[i]);
				DBUtil.commitTranscation();
			}catch(Exception e){
				DBUtil.rollbackTranscation();
				e.printStackTrace();
			}
		}
		return flag;
	}
		
}
